package me.yushuai.wukong.base.convertor;

import me.yushuai.wukong.base.api.dto.CartonDTO;
import me.yushuai.wukong.base.api.dto.CreateCartonDTO;
import me.yushuai.wukong.base.api.dto.UpdateCartonDTO;
import me.yushuai.wukong.base.entity.Carton;
import me.yushuai.wukong.common.convertor.BaseConvertor;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

import java.util.List;

/**
 * @author zhoushuai@189.cn
 * @since 2022-11-21
 */
@Mapper(componentModel = "spring")
public interface CartonConvertor extends BaseConvertor<Carton, CartonDTO> {

    @Mapping(target = "cartonGroupId", ignore = true)
    @Mapping(target = "id", source = "cartonId", ignore = true)
    Carton mapToCarton(CreateCartonDTO dto);

    @Mapping(target = "warehouseId", ignore = true)
    @Mapping(target = "cartonGroupId", ignore = true)
    void mapToCarton(UpdateCartonDTO dto, @MappingTarget Carton carton);

    @Override
    @Mapping(target = "cartonGroup", ignore = true)
    CartonDTO mapToDto(Carton carton);

    List<CartonDTO> mapToDtoList(List<Carton> cartons);
}
